<extend name="_layout/main"/>
<block name="head">
    <style>
        #main {
            padding-top: 52px;
        }
    </style>
</block>
<block name="top">
    <header class="mui-bar mui-bar-nav report-header box-s" id="header">
        <a href="{:U('Member/goods_order')}"><i class="iconfont icon-fanhui fl"></i></a>
        <p>商品评价</p>
    </header>
</block>
<block name="content">
    <div id="main" class="mui-clearfix">
        <form id="commentForm" action="{:U('goods_comment')}">
            <input type="hidden" name="id" value="{$order['id']}">
            <volist name="goods" id="item">
                <div class="assess clearfloat">
                    <div class="top clearfloat box-s">
                        <div class="tu fl clearfloat">
                            <img src="{$item.goods_thumb}"/>
                        </div>
                        <div class="pinfen fl clearfloat">
                            <p class="tit">{$item.goods_name}</p>
                        </div>
                    </div>
                    <textarea rows="4" name="message[{$item.goods_id}]" placeholder="请写下对宝贝的感受吧，对他人帮助很大哦"></textarea>
                </div>
            </volist>
        </form>
    </div>
    <a href="javascript:void(0);" id="btn-save" class="address-add fl ra3">
        提交
    </a>
</block>
<block name="scripts">
    <script>
        $(document).on('click', '#btn-save', function (e) {
            e.preventDefault();
            var form = $("#commentForm");
            if (!form.is('form')) {
                return;
            }

            var url = form.attr('action');
            if (!url || url == '') {
                return;
            }
            var data = form.serialize();
            mui.confirm('确认提交评论吗？', '提示', ['提交', '取消'], function (btn) {
                if (btn.index == 0) {
                    $.post(url, data, function (xdata) {
                        if (xdata.status == 'success' && xdata.data.url) {
                            mui.alert(xdata.message, '提示', function () {
                                document.location.href = xdata.data.url;
                            });
                        } else {
                            mui.toast(xdata.message);
                        }
                    }, 'json')
                }
            })

        })
    </script>
</block>